<?php

namespace App\Http\Controllers\web;

use App\Http\Controllers\Controller;
use App\Http\Service\Redisd;
use App\Models\StoreProduct;
use App\Models\SystemStore;
use Illuminate\Http\Request;

class Shop extends Controller
{
    /**
     * 查询门店
     * @return array
     */
    public function shopList(){
        try {
            $data=SystemStore::get();
            Redisd::getInstance()->set('111',1111);
            if ($data){
                return   ['code'=>20000,'msg'=>'查询成功','data'=>$data];
            }
            throw new \Exception('查询失败');
        }catch (\Exception $e){
            return  ['code'=>5000,'msg'=>$e->getMessage()];
        }
    }
    /**
     * 门店下的商品查询
     * @param Request $request
     * @return array
     */
    public function ShopGoods(Request $request){
        $shopId=$request->get('shopId');
        try {
            $data=StoreProduct::where('mer_id',$shopId)->paginate(5);
            if ($data){
                return   ['code'=>20000,'msg'=>'查询成功','data'=>$data];
            }
            throw new \Exception('查询失败');
        }catch (\Exception $e){
            return  ['code'=>5000,'msg'=>$e->getMessage()];
        }
    }
}
